<template>
	<!-- addpersonnel添加店员 -->
	<view class="a_wp">
		<uni-card :border="false" spacing="5px 5px" padding="0" :is-shadow="false" is-full>
			<text class="message">添加店员后，该店员可获得扫码核销权限</text>
		</uni-card>
		<view class="a_list">
			<view class="a_item" v-for="(item,index) in list" :key="item.mid">
				<image :src="item.avatar" mode=""></image>
				<view class="a_info">
					<view class="">{{item.nickname}}</view>
					<view class="a_phone">电话：{{item.mobile}}</view>
				</view>
				<button class="a_button" size="mini" type="warn" @click="deleteTap(index)">删除</button>
			</view>
		</view>
		<view class="loading_message">
			<image v-if="isloading" src="../../static/business/loading.gif"></image>
			<view v-if="list.length<=0">到底了~</view>
		</view>
		<view class="a_add" @click="$navTo('/pages/groupmenu/addpersonnel?uid='+uid)">添加店员</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				uid: '',
				list: [],
				isloading: false,
				isempty: false,
			}
		},
		onLoad(options) {
			this.uid = options.uid;
			this.getList();
		},
		methods: {
			deleteTap(v) {
				let that = this;
				uni.showModal({
					title: '提示',
					content: '确认删除',
					success(res) {
						if (res.confirm) {
							that.$axios('info/memberDel', 'POST', 'supplier', {
								uid: that.uid,
								mid: that.list[v].mid
							}).then(res => {
								if (res.data.code == 200) {
									that.$api.msg(res.data.data);
									that.list.splice(v, 1);
								}
							})
						}
					}
				})
			},
			getList() {
				this.isloading = true;
				this.$axios('info/memberList', 'POST', 'supplier', {
					uid: this.uid,
				}).then(res => {
					this.isloading = false;
					if (res.data.code == 200) {
						this.list = this.list.concat(res.data.data);
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f2f2f2;
		padding-bottom: 130upx;
	}

	.a_list {
		padding-top: 20upx;
	}

	.a_item {
		background-color: #fff;
		display: flex;
		align-items: center;
		padding: 20upx;
		margin-bottom: 20upx;
	}

	.a_item image {
		border-radius: 10upx;
		height: 80upx;
		width: 80upx;
	}

	.a_info {
		line-height: 40upx;
		padding-left: 20upx;
		flex: 1;
	}

	.a_phone {
		color: $font-color-light;
		font-size: $font-sm;
	}

	.loading_message {
		padding: 40upx;
		color: #0062CC;
		text-align: center;
	}

	.loading_message image {
		height: 50upx;
		width: 50upx;
	}

	.a_add {
		background-color: $base-color;
		border-radius: 40upx;
		color: #fff;
		line-height: 70upx;
		position: fixed;
		left: 7%;
		bottom: 30upx;
		text-align: center;
		width: 86%;
		box-shadow: 4rpx 5rpx 17rpx 7rpx #ddd;
	}
</style>